package edu.wpi.first.wpilibj.positioning;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;

/**
 *
 * @author 8349
 */
public class Path implements Iterator<Coordinates> {
    
    private final ArrayList<Coordinates> coordList;
    private final int size;
    
    public Path (Coordinates... coords){
        size = coords.length;
        coordList = new ArrayList<Coordinates>((int) (size * 1.4));
        coordList.addAll(Arrays.asList(coords));
    }
    
    public Path (Map<Long, Coordinates> pathMap){
        size = pathMap.size();
        coordList = new ArrayList<Coordinates>((int) (size * 1.4));
        for (Iterator<Map.Entry<Long, Coordinates>> it = pathMap.entrySet().iterator();it.hasNext();){
            Map.Entry<Long, Coordinates> e = it.next();
            coordList.add(e.getValue());
        }
    }

    private int itIndex;

    @Override
    public boolean hasNext() {
        return size >= itIndex;
    }

    @Override
    public Coordinates next() {
       return coordList.get(itIndex++);
    }

    @Override
    public void remove() {
        coordList.remove(itIndex);
    }
    
}
